package com.ssy.lingxi.report.repository.report;

import com.ssy.lingxi.report.entity.report.AppBacklogNoticeDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

/**
 * App待办通知类
 * @author 伍将
 * @date 2021/1/18
 * @version 2.0.0
 */
public interface AppBacklogNoticeRepository extends JpaRepository<AppBacklogNoticeDO, Long>, JpaSpecificationExecutor<AppBacklogNoticeDO> {

    /**
     * 删除通知
     * @param memberId 会员id
     * @param roleId 会员角色id
     * @param dataSource 数据源
     * @param operateType 操作类型
     * @param dataId 数据id
     */
    @Transactional
    @Modifying
    @Query(value = "delete from rep_app_backlog_notice where member_id=:memberId and role_id=:roleId and data_source=:dataSource and operate_type=:operateType and data_id=:dataId", nativeQuery = true)
    void deleteNotice(Long memberId, Long roleId, Integer dataSource, Integer operateType, Long dataId);

    /**
     * 根据会员id与会员角色id查询待办总数
     * @param memberId 会员id
     * @param roleId 会员角色id
     * @return 待办总数
     */
    long countByMemberIdAndAndRoleId(Long memberId, Long roleId);
}
